<?php
    require_once "smarty/Smarty.class.php";
    require_once "adodb5/adodb.inc.php";
    require_once "utils.php";
    date_default_timezone_set('America/Buenos_Aires');

    function loadClass($class){
        require_once dirname(__FILE__)."/classes/".$class.".class.php";
    }

    spl_autoload_register("loadClass");

    function getSmarty(){
    //Smarty.
    $smarty = new Smarty();    
    $smarty->setTemplateDir('./templates/');
    $smarty->setCompileDir('./templates_c/');
    $smarty->setConfigDir('./configs/');
    $smarty->setCacheDir('./cache/');

    return $smarty;
    }
    


    function getADODB(){
    //ADODB
    $conf = new Configuracion();
    $db = ADONewConnection($conf->get('DB_DRIVER'));
    $db->debug = $conf->get('DEBUG');
                           
    $db->Connect($conf->get('DB_HOST').':'.$conf->get('DB_PORT'),
                 $conf->get('DB_USER'),
                 $conf->get('DB_PASSWORD'),
                 $conf->get('DB_DATABASE')
                );
    return $db;
    }


    function getPDO(){
        $conf = new Configuracion();
        $dsn = $conf->get('DB_DRIVER').":host=".$conf->get('DB_HOST').";dbname=";
        $dsn.= $conf->get('DB_DATABASE').";charset=utf8";
        
        $pdo = new PDO($dsn, $conf->get('DB_USER'),$conf->get('DB_PASSWORD'));
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        return $pdo;
    
    }

?>